jQuery(document).ready(function(){
	
	
	$j("#addpage_input").bind("keyup", function(){
		
		var input_data =  $j("#addpage_input").attr("value") ;
		var action     =  $j("#addpage_form").attr("action");
		
		
		$j.ajax({
			type: "POST",
			url:  action,
			data: "data="+input_data,
			dataType: "json",
			success: function ( data, status ){
				
				if ( data.status == "false" )
				{
					$j("#message_box").addClass("error");
					$j("#message_box").fadeIn("normal", function(){
						$j("#message").text( data.message );
					});
					$j("#notice_ok").fadeOut("normal");
				}
				else if ( data.status == "true" )
				{
					$j("#message_box").removeClass("error");
					$j("#message_box").fadeIn("normal", function(){
						$j("#message").text( data.message );
					});
					$j("#notice_ok").fadeIn("normal");
				}
				
			}
		});

	});

	
	function close()
	{
		
	}
	
	$j("#notice_ok").bind("click", function(){
		
		var input_data =  $j("#addpage_input").attr("value") ;
		var action     =  $j("#addpage_form").attr("action");
		
		
		$j.ajax({
			type: "POST",
			url:  action,
			data: "data="+input_data+"&action=add",
			dataType: "json",
			success: function ( data, status ){
				
				if ( data.status == "false" )
				{
					$j("#message_box").addClass("error");
					$j("#message_box").fadeIn("normal", function(){
						$j("#message").text( data.message );
					});
				}
				else if ( data.status == "true" )
				{
					$j("#message_box").removeClass("error");
					$j("#message_box").fadeIn("normal", function(){
						$j("#message").text( data.message );
					});
					setTimeout('$j("#addpage").fadeOut("fast");', 1000);
				}
				
			}
		});	
			
	});
	
});